import requests
from multiprocessing import Pool
import logging

URL = 'http://www..org/vod-detail-id-{}.html'


def func(interval):
    print(interval)
    return interval


def func_result(ret):
    print('return :')


def download_web(index) -> None:
    print(index)
    response = requests.get(URL.format(index))
    content = response.content
    print(content)
    s = content.decode('utf-8', 'ignore')
    with open("E:/hero_time/details/" + str(index), mode='w', encoding='utf-8') as f:
        f.write(s)


def foo(index):
    print(index)


if __name__ == '__main__':
    result = []
    with Pool(processes=4) as pool:
        for a in range(4000, 5000):
            res = pool.apply_async(download_web, (a,))
            result.append(res)

        for r in result:
            r.get(timeout=1000)
